/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package uttt.edu.mx.datos;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.util.List;
import uttt.edu.mx.conexion.Conexion;
import uttt.edu.mx.entidades.EntCambioDeGrupo;

/**
 *
 * @author Jesus Santiago
 */
public class CtrlCambioDeGrupo implements IGeneral {

    private PreparedStatement st = null;
    private Connection conn;

    @Override
    public boolean insertar(Object _Obj) {
        EntCambioDeGrupo grupo = (EntCambioDeGrupo) _Obj;
        try {
            Conexion datos = new Conexion();
            Connection conn = datos.getConexion();
            if (conn != null) {
                String query = "INSERT INTO historial (id_Persona, grupo, fecha ) "
                        + " VALUES ('" + grupo.getIdPersona()
                        + "' , '" + grupo.getGrupoAnterior()
                        + "' , '" + grupo.getFechaDeCambio() + "');";
                st = conn.prepareStatement(query);
                int executeUpdate = st.executeUpdate();
                return true;
            } else {
                return false;
            }
        } catch (Exception ex) {
            System.out.println(ex.getMessage());
            return false;
        }
    }

    @Override
    public boolean eliminar(Object _Obj) {
        throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
    }

    @Override
    public List<Object> consultar(Object _Obj) {
        throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
    }

    @Override
    public boolean modificar(Object _Obj) {
        throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
    }
}
